﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="LinkInput.ascx.cs" Inherits="admin_webparts_Plug_ins_HighlightLink_LinkInput" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %>
<%@ Import Namespace="NTTHAO.Web.BL.HighlightLink" %>
<div class="tip">
    <h1 style="left: 0px; position: relative;"><%=LanguageUtility.GetLanguageText("HLINK_INPUT") %></h1>
    <div style="display: block; width: 32px; height: 32px; float: right; position: relative; top: -27px;"><a title="<%=LanguageUtility.GetLanguageText("CLICK_RETURN", Session) %>" href="<%=_BackLink %>"><img src="resources/images/Back.png" alt="" /></a></div>
</div>
<form id="aspnetForm" runat="server" method="post" onsubmit="return doSubmit();">
<p>
    <span id="spSave" class="yui-button yui-link-button yuibtn yuibtn-icon btnsave"><span class="first-child"><input id="btnSave" type="submit" value="Save" runat="server" onserverclick="btnSave_Click" /></span></span>
    <span id="spCancel" class="yui-button yui-link-button yuibtn yuibtn-icon btncancel"><span class="first-child"><a href="<%=_BackLink %>" tabindex="0"><%=LanguageUtility.GetLanguageText("CANCEL", Session)%></a></span></span>
</p><%if (_ErrorMsg != string.Empty) { %>
<div class="tip" style="margin-top: 10px;color: Red;background-color: moccasin;"><%=_ErrorMsg %></div><%} %>
<script type="text/javascript">
    YAHOO.util.Event.onContentReady('spSave', function () {
        var spSave = new YAHOO.widget.Button("spSave");
    });
    YAHOO.util.Event.onContentReady('spCancel', function () {
        var spCancel = new YAHOO.widget.Button("spCancel");
    });
    
function saleOffChange(checked) {
    document.getElementById('trSaleOffPrice').style.display = (checked ? '' : 'none');
    
    NTTHAO.gridview.init(document.getElementById('tbInput'));
    //viewEvenOdd();
}

function viewEvenOdd() {
    var tbInput = document.getElementById('tbInput');
    var index = 0;
    for(var i = 0; i < tbInput.rows.length; i++) {
        if (tbInput.rows[i].style.display.toLowerCase() != 'none') {
            tbInput.rows[i].setAttribute('class', index%2==0?'even':'odd');
            index++;
        }
    }
}
    
YAHOO.util.Event.onDOMReady(function() {
    document.getElementById('<%=txtTitle.ClientID %>').focus();
    saleOffChange(document.getElementById('<%=chkSaleOff.ClientID %>').checked);
    
    //viewEvenOdd();
});

function doSubmit() {
    var oDom = YAHOO.util.Dom;
    
    var txtTitle = oDom.get("<%=this.txtTitle.ClientID %>");
    var txtHref = oDom.get("<%=this.txtHref.ClientID %>");
    var fuImage = oDom.get("<%=this.fuImage.ClientID %>");
    var fuThumb = oDom.get("<%=this.fuThumb.ClientID %>");
    var txtPrice = oDom.get("<%=this.txtPrice.ClientID %>");
    var chkSaleOff = oDom.get("<%=this.chkSaleOff.ClientID %>");
    var txtSaleOffPrice = oDom.get("<%=this.txtSaleOffPrice.ClientID %>");
    var imageEx = "<%=Constant.IMAGE_FILE_EXTENTIONS %>".split(" ");
    var errorMessage = "";
    
    
    errorMessage = CheckFieldString("noblank", txtTitle, '<%=LanguageUtility.GetLanguageText("BLANK_HEADER") %>');
    if(errorMessage != "")
    {
        alert(errorMessage);
        txtTitle.select();
        txtTitle.focus();
        return false;
    }
    
    <%if (_Link == null && _Group.ImageRequired) { %>
    errorMessage = CheckFieldString("noblank", fuImage, '<%=LanguageUtility.GetLanguageText("INVALID_IMAGE_FILE") %>');
    if(errorMessage != "")
    {
        alert(errorMessage);
        fuImage.select();
        fuImage.focus();
        return false;
    }
    <%} %>
    var imgFileName = Trim(fuImage.value);
    if (!checkFileType(imgFileName, imageEx)) {
        alert('<%=LanguageUtility.GetLanguageText("INVALID_IMAGE_FILE") %>');
        fuImage.focus();
        return false;
    }
    <%if (_Link == null && _Group.ImageRequired) { %>
    if(fuThumb.parentNode.parentNode.style.display.toLowerCase() != 'none') {
        errorMessage = CheckFieldString("noblank", fuThumb, '<%=LanguageUtility.GetLanguageText("INVALID_IMAGE_FILE") %>');
        if(errorMessage != "")
        {
            alert(errorMessage);
            fuThumb.select();
            fuThumb.focus();
            return false;
        }
    }
    <%} %>
    if(fuThumb.parentNode.parentNode.style.display.toLowerCase() != 'none') {
        imgFileName = Trim(fuThumb.value);
        if (!checkFileType(imgFileName, imageEx)) {
            alert('<%=LanguageUtility.GetLanguageText("INVALID_IMAGE_FILE") %>');
            fuThumb.focus();
            return false;
        }
    }
    
    if(txtPrice.parentNode.parentNode.style.display.toLowerCase() != 'none') {
        errorMessage = CheckFieldString("noblank", txtPrice, '<%=LanguageUtility.GetLanguageText("INVALID_NUMBER") %>');
        errorMessage += CheckFieldString("integer", txtPrice, '<%=LanguageUtility.GetLanguageText("INVALID_NUMBER") %>');
        if(errorMessage != "")
        {
            alert(errorMessage);
            txtPrice.select();
            txtPrice.focus();
            return false;
        }
    }
    
    if(txtSaleOffPrice.parentNode.parentNode.style.display.toLowerCase() != 'none') {
        errorMessage = CheckFieldString("noblank", txtSaleOffPrice, '<%=LanguageUtility.GetLanguageText("INVALID_NUMBER") %>');
        errorMessage += CheckFieldString("integer", txtSaleOffPrice, '<%=LanguageUtility.GetLanguageText("INVALID_NUMBER") %>');
        if(errorMessage != "")
        {
            alert(errorMessage);
            txtSaleOffPrice.select();
            txtSaleOffPrice.focus();
            return false;
        }
    }
    
    return true;
}
</script>
<table width="100%" cellspacing="1" cellpadding="3" border="1" style="margin-top: 10px;" class="grid" id="tbInput">
    <tr>
        <td width="150px" align="right"><%=LanguageUtility.GetLanguageText("TITLE", Session) %><span style="color: #ff0000;">&nbsp;*</span>:</td>
        <td><asp:TextBox ID="txtTitle" runat="server" Width="500px"></asp:TextBox></td>
    </tr>
    <tr>
        <td align="right"><%=LanguageUtility.GetLanguageText("LINK", Session)%><span style="color: #ff0000;">&nbsp;*</span>:</td>
        <td><asp:TextBox ID="txtHref" runat="server" Width="500px" Text="#"></asp:TextBox></td>
    </tr>
    <tr>
        <td align="right"><%=LanguageUtility.GetLanguageText("TARGET", Session)%><span style="color: #ff0000;">&nbsp;*</span>:</td>
        <td>
            <asp:DropDownList runat="server" ID="cmbTarget" Width="200px">
                <asp:ListItem Value="_self">Self</asp:ListItem>
                <asp:ListItem Value="_blank">Blank</asp:ListItem>
                <asp:ListItem Value="_parent">Parent</asp:ListItem>
                <asp:ListItem Value="_top">Top</asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
        <td align="right"><%=LanguageUtility.GetLanguageText("ACTIVE", Session) %><span style="color: #ff0000;">&nbsp;*</span>:</td>
        <td><asp:CheckBox ID="chkActive" runat="server" Text="Activated" Checked="true" /></td>
    </tr>
    <tr style="<%=_Group.ImageAvailable ? "" : "display: none;" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("IMAGE", Session)%><span style="color: #ff0000; <%=(_Link == null && _Group.ImageRequired) ? "" : "display: none;" %>">&nbsp;*</span>:</td>
        <td>
            <asp:FileUpload ID="fuImage" runat="server"/>
            &nbsp;<div style="color: mediumblue; background-color: moccasin; padding: 3px 10px 3px 10px; display: inline;"><%=Constant.IMAGE_FILE_EXTENTIONS %></div>
            &nbsp;<div style="color: mediumblue; background-color: moccasin; padding: 3px 10px 3px 10px; display: inline;"><%=(this._Group.DefaultWidth < 1) ? "*" : this._Group.DefaultWidth.ToString("0")%> x <%=(this._Group.DefaultHeight < 1) ? "*" : this._Group.DefaultHeight.ToString("0")%> pixels</div>
        </td>
    </tr>
    <tr style="<%=(_Group.ThumbImageOption == ThumbImageOptions.Upload) ? "" : "display: none;" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("MINI_IMAGE", Session)%><span style="color: #ff0000; <%=(_Link == null && _Group.ImageRequired) ? "" : "display: none;" %>">&nbsp;*</span>:</td>
        <td>
            <asp:FileUpload ID="fuThumb" runat="server"/>
            &nbsp;<div style="color: mediumblue; background-color: moccasin; padding: 3px 10px 3px 10px; display: inline;"><%=Constant.IMAGE_FILE_EXTENTIONS %></div>
            &nbsp;<div style="color: mediumblue; background-color: moccasin; padding: 3px 10px 3px 10px; display: inline;"><%=(this._Group.ThumbImageWidth < 1) ? "*" : this._Group.ThumbImageWidth.ToString("0")%> x <%=(this._Group.ThumbImageHeight < 1) ? "*" : this._Group.ThumbImageHeight.ToString("0")%> pixels</div>
        </td>
    </tr>
    <tr style="<%=_Group.PriceAvailable ? "" : "display: none;" %>"><td colspan="2">&nbsp;</td></tr>
    <tr style="<%=_Group.PriceAvailable ? "" : "display: none;" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("PRICE", Session)%><span style="color: #ff0000;">&nbsp;*</span>:</td>
        <td><asp:TextBox ID="txtPrice" runat="server" Width="400px" Text="0"></asp:TextBox></td>
    </tr>
    <tr style="<%=_Group.PriceAvailable && _Group.SaleOffAvailable ? "" : "display: none;" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("SALEOFF", Session)%>:</td>
        <td><input type="checkbox" id="chkSaleOff" runat="server" onclick="javascript: saleOffChange(this.checked);" /><label for="<%=chkSaleOff.ClientID %>"><%=LanguageUtility.GetLanguageText("SALEOFF", Session)%></label></td>
    </tr>
    <tr style="<%=_Group.PriceAvailable && _Group.SaleOffAvailable ? "" : "display: none;" %>" id="trSaleOffPrice">
        <td align="right"><%=LanguageUtility.GetLanguageText("SALEOFF_PRICE", Session)%><span style="color: #ff0000;">&nbsp;*</span>:</td>
        <td>
            <asp:TextBox ID="txtSaleOffPrice" runat="server" Width="400px" Text="0"></asp:TextBox>
        </td>
    </tr>
    <tr style="<%=_Group.PriceAvailable && _Group.CurrencyAvailable ? "" : "display: none;" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("CURRENCY", Session)%>:</td>
        <td><asp:TextBox ID="txtCurrency" runat="server" Width="100px" Text="VNĐ"></asp:TextBox></td>
    </tr>
    <tr style="<%=_Group.PriceAvailable && _Group.UnitAvailable ? "" : "display: none;" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("UNIT", Session)%>:</td>
        <td><asp:TextBox ID="txtUnit" runat="server" Width="400px"></asp:TextBox></td>
    </tr>
    <tr style="<%=(_Group.DescriptionOption != DescriptionOptions.None) ? "" : "display: none;" %>"><td colspan="2">&nbsp;</td></tr>
    <tr style="<%=(_Group.DescriptionOption == DescriptionOptions.Short) ? "" : "display: none;" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("DESCRIPTION", Session)%>:</td>
        <td><asp:TextBox ID="txtDescription" runat="server" Width="600px" Height="100px" TextMode="MultiLine"></asp:TextBox></td>
    </tr>
    <tr style="<%=(_Group.DescriptionOption == DescriptionOptions.Long) ? "" : "display: none;" %>">
        <td align="right"><%=LanguageUtility.GetLanguageText("CONTENT", Session)%>:</td>
        <td><CKEditor:CKEditorControl ID="_ContentCKEditor" runat="server" BasePath="Resources/js/ckeditor" Font-Names="Verdana" FontNames="Verdana/Verdana, Geneva, sans-serif&#13;&#10;Arial/Arial, Helvetica, sans-serif;&#13;&#10;Comic Sans MS/Comic Sans MS, cursive;&#13;&#10;Courier New/Courier New, Courier, monospace;&#13;&#10;Georgia/Georgia, serif;&#13;&#10;Lucida Sans Unicode/Lucida Sans Unicode, Lucida Grande, sans-serif;&#13;&#10;Tahoma/Tahoma, Geneva, sans-serif;&#13;&#10;Times New Roman/Times New Roman, Times, serif;&#13;&#10;Trebuchet MS/Trebuchet MS, Helvetica, sans-serif;" Height="450px" Skin="v2" TemplatesFiles="Resources/js/ckeditor/plugins/templates/templates/default.js" ToolbarFull="Source|-|NewPage|-|Templates&#13;&#10;Cut|Copy|Paste|PasteText|PasteFromWord|-|Print|SpellChecker|Scayt&#13;&#10;Undo|Redo|-|Find|Replace|-|SelectAll|RemoveFormat&#13;&#10;Form|Checkbox|Radio|TextField|Textarea|Select|Button|ImageButton|HiddenField&#13;&#10;/&#13;&#10;Bold|Italic|Underline|Strike|-|Subscript|Superscript&#13;&#10;NumberedList|BulletedList|-|Outdent|Indent|Blockquote|CreateDiv&#13;&#10;JustifyLeft|JustifyCenter|JustifyRight|JustifyBlock&#13;&#10;BidiLtr|BidiRtl&#13;&#10;Link|Unlink|Anchor&#13;&#10;Image|SelectImage|Flash|MediaEmbed|Table|HorizontalRule|Smiley|SpecialChar|PageBreak|Iframe&#13;&#10;/&#13;&#10;Styles|Format|Font|FontSize&#13;&#10;TextColor|BGColor&#13;&#10;Maximize|ShowBlocks|-|About" ></CKEditor:CKEditorControl></td>
    </tr>
</table>
<p style="text-align: left; margin-top: 10px;">
    <span id="spSave2" class="yui-button yui-link-button yuibtn yuibtn-icon btnsave"><span class="first-child"><input id="btnSave2" type="submit" value="Save" runat="server" onserverclick="btnSave_Click" /></span></span>
    <span id="spCancel2" class="yui-button yui-link-button yuibtn yuibtn-icon btncancel"><span class="first-child"><a href="<%=_BackLink %>"><%=LanguageUtility.GetLanguageText("CANCEL", Session)%></a></span></span>
</p>
<script type="text/javascript">
    YAHOO.util.Event.onContentReady('spSave2', function () {
        var spSave2 = new YAHOO.widget.Button("spSave2");
    });
    YAHOO.util.Event.onContentReady('spCancel2', function () {
        var spCancel2 = new YAHOO.widget.Button("spCancel2");
    });
</script>
</form>
